//
//  PTRecorderCell.m
//  PocketTutor
//
//  Created by yate1996 on 15/6/9.
//  Copyright (c) 2015年 yate1996. All rights reserved.
//

#import "PTRecorderCell.h"
#import "PTRecorder.h"
#import "PTRecorderView.h"
#import "PTRecorderFrame.h"
@interface PTRecorderCell ()

@property (nonatomic, weak) PTRecorderView *recorderView;
-(void) buttonClick:(UIButton *)button;
@end
@implementation PTRecorderCell

+(instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *ID = @"recorder";
    PTRecorderCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if(!cell) {
        cell = [[PTRecorderCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}


-(void)setRecorderFrame:(PTRecorderFrame *)recorderFrame
{
    _recorderFrame = recorderFrame;
    [self.recorderView setRecorderFrame:recorderFrame];

}

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self) {
        
        PTRecorderView *recorderView = [[PTRecorderView alloc]init];
        [self.contentView addSubview:recorderView];
        self.recorderView = recorderView;
        self.backgroundColor = [UIColor clearColor];
        [self.recorderView.lessonTitleButton addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
        [self.recorderView.actionOrCancelButton addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
//        [self.recorderView.countDownButton addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
        
    }
    
    return self;
    
}

-(void) buttonClick:(UIButton *)button
{
    
    self.selectButtonType = (int)button.tag;
    if ([self.delegate respondsToSelector:@selector(didSelectedButton:UIButton:)]) {
        [self.delegate didSelectedButton:(int)button.tag UIButton:button];
    
    }
}
@end
